package com.gitee.wsl.mathematics.matrix.ext


import com.gitee.wsl.mathematics.matrix.mat2.Matrix2
import com.gitee.wsl.mathematics.matrix.mat2.MutableMatrix2
import com.gitee.wsl.mathematics.matrix.mat3.Matrix3
import com.gitee.wsl.mathematics.matrix.mat3.MutableMatrix3
import com.gitee.wsl.mathematics.matrix.mat4.Matrix4
import com.gitee.wsl.mathematics.matrix.mat4.MutableMatrix4


infix fun<T:Number> MutableMatrix2<T, *, *>.power(n: Int) {
    require(n > 0)
    val temp = this.copySelf() as Matrix2<T, *, *>
    for (i in 1 until n)
        this *= temp
}

infix fun<T:Number> MutableMatrix3<T, *, *>.power(n: Int) {
    require(n > 0)
    val temp = this.copySelf() as Matrix3<T, *, *>
    for (i in 1 until n)
        this *= temp
}

infix fun<T:Number> MutableMatrix4<T, *, *>.power(n: Int) {
    require(n > 0)
    val temp = this.copySelf() as Matrix4<T, *, *>
    for (i in 1 until n)
        this *= temp
}